<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" class="ipt1" />
    <select>
      <option>+</option>
      <option>-</option>
      <option>*</option>
      <option>/</option>
    </select>
    <input type="text" class="ipt2" />
    <button>点击运算</button>
    <input type="text" class="ipt3" />
  </body>
</html>
<script>
  var oIpt1 = document.querySelector(".ipt1");
  var oIpt2 = document.querySelector(".ipt2");
  var oIpt3 = document.querySelector(".ipt3");
  var oBtn = document.querySelector("button");
  var oSelect = document.querySelector("select");
  oBtn.onclick = function () {
    switch (oSelect.value) {
      case "+":
        oIpt3.value = oIpt1.value * 1 + oIpt2.value * 1;
        break;
      case "-":
        oIpt3.value = oIpt1.value * 1 - oIpt2.value * 1;
        break;
      case "*":
        oIpt3.value = oIpt1.value * 1 * oIpt2.value * 1;
        break;
      case "/":
        oIpt3.value = ((oIpt1.value * 1) / oIpt2.value) * 1;
        break;

      default:
        break;
    }
  };
</script>
